//
//  LRChoiceController.m
//  BCNADemo
//
//  Created by 马东朝 on 2018/5/16.
//  Copyright © 2018年 马东朝. All rights reserved.
//

#import "LRChoiceController.h"

@interface LRChoiceController ()
{
    UIImageView *logoView;
    UILabel *logoText;
    UIButton *loginBtn;
    UIButton *registBtn;
}
@end

@implementation LRChoiceController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor colorWithHexString:@"#12121f"];
    self.but.hidden = YES;
    [self addSubViews];
}
- (void)addSubViews{
    [self addLogo];///LOGO和文字
    [self addLoginBtnAndRegistBtn];///登录注册按钮
    //    [self addThirdPartLoginBtn];///第三方登录
}
#pragma mark
///LOGO和文字
- (void)addLogo{
    logoView= [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kWidth(230), kHeight(230 * 169/131))];
    logoView.center = CGPointMake(kScreenWidth/2, kHeight(290 + 230  * 169/262));
    [self.view addSubview:logoView];
    logoView.image = [UIImage imageNamed:@"LOGO@3x.png"];
    logoText = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(logoView.frame) + kHeight(20), ScreenWidth, kHeight(60))];
    logoText.center = CGPointMake(kScreenWidth/2 + kWidth(16), CGRectGetMaxY(logoView.frame) + kHeight(60));
    [self.view addSubview:logoText];
    logoText.text = @"Welcone to Golink";
    logoText.font = [UIFont systemFontOfSize:kHeight(80)];
    logoText.textColor = [UIColor whiteColor];
    logoText.textAlignment = NSTextAlignmentCenter;
}
#pragma mark
///登录注册按钮
- (void)addLoginBtnAndRegistBtn{
    loginBtn = [self  setBtnWithFrame:CGRectMake(kWidth(90), CGRectGetMaxY(logoText.frame) + kHeight(260), ScreenWidth-kWidth(180), kHeight(150)) title:StringWithKey(@"LRVC0")];
    loginBtn.backgroundColor = [UIColor colorWithHexString:@"#40b5f8"];
    loginBtn.tag = 101;
    
    [loginBtn setTintColor:[UIColor whiteColor]];
    [self.view addSubview:loginBtn];
    registBtn = [self  setBtnWithFrame:CGRectMake(kWidth(90), CGRectGetMaxY(loginBtn.frame) + kHeight(60), ScreenWidth-kWidth(180), kHeight(150)) title:StringWithKey(@"LRVC1")];
    
    registBtn.backgroundColor = [UIColor whiteColor];
    //[registBtn setTintColor:[UIColor colorWithHexString:@"#40b5f8"]];
    [registBtn setTitleColor:[UIColor colorWithHexString:@"#40b5f8"] forState:UIControlStateNormal];
    registBtn.tag = 102;
    [self.view addSubview:registBtn];
    
    
}
- (UIButton *)setBtnWithFrame:(CGRect) frame title:(NSString *)title{
    UIButton *abutton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    abutton.frame = frame;
    [abutton setTitle:title forState:UIControlStateNormal];
    abutton.layer.cornerRadius = frame.size.height/2;
    abutton.layer.masksToBounds = YES;
    [abutton addTarget:self action:@selector(handleLoginBtn:) forControlEvents:UIControlEventTouchUpInside];
    return abutton;
}
- (void)handleLoginBtn:(UIButton *)sender{
    
    switch (sender.tag) {
        case 101:
        {
            [self.navigationController pushViewController:[[LoginController alloc]init] animated:YES];
        }
            break;
        case 102:
        {
            [self.navigationController pushViewController:[[RegistController alloc]init] animated:YES];
        }
            break;
            
        default:
            break;
    }
}
#pragma mark 第三方登录
- (void)addThirdPartLoginBtn{
    NSArray *iconArr = @[@"QQ@2x.png", @"wechat@2x.png", @"facebook@2x.png"];
    CGFloat wid  = (ScreenWidth - kWidth(360) - kHeight(120) * 3)/2;
    for (int i = 0; i < 3; i++) {
        UIButton *iconBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [iconBtn setImage:[UIImage imageNamed:iconArr[i]] forState:UIControlStateNormal];
        iconBtn.frame = CGRectMake(kWidth(180) + (wid + kHeight(120)) * i, ScreenHeight-kHeight(320), kHeight(120), kHeight(120));
        iconBtn.tag = 200 + i;
        [iconBtn addTarget:self action:@selector(handleThirdLogin:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:iconBtn];
    }
    
    UILabel *label1  = [[UILabel alloc] initWithFrame:CGRectMake(0, ScreenHeight-kHeight(320+ 90) -20, ScreenWidth, 20)];
    label1.textAlignment = NSTextAlignmentCenter;
    label1.text = @"使用第三方登录";
    label1.textColor = [UIColor colorWithHexString:@"#5e5f79"];
    label1.font = [UIFont systemFontOfSize:18];
    [self.view addSubview:label1];
}
- (void)handleThirdLogin:(UIButton *)sender{
    switch (sender.tag) {
        case 200:
        {
            ///QQ登录
        }
            break;
        case 201:
        {
            ///微信登录");
        }
            break;
        case 202:
        {
            ///FaceBook登录");
        }
            break;
            
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
